package io.polly.ldz.reactor.mvc;

import io.polly.ldz.reactor.context.RestResponse;
import io.polly.ldz.reactor.context.SystemCode;
import io.polly.ldz.reactor.viewmodel.UserResponseVM;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author ldz112@163.com
 * @Classname UserController
 * @Version V1.0
 * @Description controller
 * @Date 2024/10/14 9:51
 * Copyright (C) 2023 All Rights Reserved
 */
@RestController("AdminUserController")
@RequestMapping(value = "/v1.0/user")
public class UserController {

    @RequestMapping(value = "/select/{id}", method = RequestMethod.GET)
    public RestResponse<UserResponseVM> select(@PathVariable Integer id) {

        if(id==1) {
            UserResponseVM userVm = new UserResponseVM();
            userVm.setId(id);
            userVm.setUserName("admin");
            return RestResponse.ok(userVm);
        }
        else  {
            return new RestResponse<>(SystemCode.InnerError);
        }

    }

    @RequestMapping(value = "/register", method = RequestMethod.GET)
    public RestResponse<String> register() {
        return  RestResponse.ok("hello");
    }
}
